package de.preissler.jointest;

import java.util.List;

import me.prettyprint.hector.api.Keyspace;
import me.prettyprint.hector.api.beans.Row;
import me.prettyprint.hector.api.factory.HFactory;
import me.prettyprint.hector.api.query.RangeSubSlicesQuery;

public class DAXPreSaved implements DAX
{
	private static final String ISIN = "DE0008469008";
	private static final String VALUE = "value";

	public void getDAXValues(List<String> dates, Keyspace keyspace, double[] result)
	{
		//DAX Daten abrufen
		RangeSubSlicesQuery<String, String, String, Double> query = HFactory.createRangeSubSlicesQuery(keyspace, SS, SS, SS, DS);
		query.setColumnFamily(SCF);
		query.setKeys(dates.get(dates.size()-1), dates.get(0));
		query.setSuperColumn(ISIN);
		query.setColumnNames(VALUE);
		List<Row<String, String, Double>> preResult = query.execute().get().getList();
		
		//In das Format umwandeln
		for(int i = 0; i < preResult.size(); i++)
		{
			result[preResult.size()-1-i] = preResult.get(i).getColumnSlice().getColumnByName(VALUE).getValue();
		}
	}

}
